﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 设计模式.工厂模式
{
    public class ShapeFactory
    {
        public static IShape GetShape(string shapeType)
        {
            if (shapeType == null)
            {
                return null;
            }
            else if (shapeType.Equals("circle", StringComparison.OrdinalIgnoreCase))
            {
                return new Circle();
            }
            else if (shapeType.Equals("rectangle", StringComparison.OrdinalIgnoreCase))
            {
                return new Rectangle();
            }
            else if (shapeType.Equals("square", StringComparison.OrdinalIgnoreCase))
            {
                return new Square();
            }
            else
            {
                return null;
            }
        }
    }
}
